<template>
  <doc-stars v-if="!$a_config.简化登录页" />
  <div class="VPHero">
    <div class="main column flex-center ">
      <h3 class="clip动态渐变文字 文字放大显影 flex-c">{{ $a_config.欢迎词 }}</h3>
      <div class="column flex-center q-gutter-sm q-pt-sm">
        <div class="row flex-center">
          <q-avatar size="60px" class="text-center">
            <img :src="$a_config.appLogo">
          </q-avatar>
          <span class="text-h4 text-center q-pl-md">
            {{ $a_config.appName }}
          </span>
        </div>
        <q-btn v-if="!系统已熟" class="q-mt-md" color="negative" icon="restart_alt" label="系统还未初始化，点击执行！" @click="跳转初始化" />
        <q-card class="q-pa-lg " style="width: 432px;">
          <q-tabs v-model="tab" dense class="" active-color="primary" indicator-color="primary" align="justify"
            narrow-indicator>
            <q-tab name="登录" label="登录" class="" />
            <q-tab name="注册" label="注册" />
          </q-tabs>
          <q-separator />
          <q-tab-panels v-model="tab" animated>
            <q-tab-panel name="登录">
              <a登录></a登录>
            </q-tab-panel>
            <q-tab-panel name="注册">
              <a注册></a注册>
            </q-tab-panel>
          </q-tab-panels>
        </q-card>
      </div>
    </div>
    <amtf v-if="!$a_config.简化登录页"></amtf>
  </div>
</template>

<script setup lang="ts">
import DocStars from 'amtf/components/DocStars.vue'
import amtf from 'amtf/components/amtf.vue'
import a登录 from './a登录.vue';
import a注册 from './a注册.vue';
import { computed, ref } from 'vue';
const tab = ref('登录')
import { checkDB } from '@/api/initdb'

defineOptions({
  name: "Login",
})

import { useRouter } from 'vue-router'
const router = useRouter()

const 系统已熟 = ref(false)
// console.log(`import.meta.env 👉`, import.meta.env)

async function 证系统() {
  const res = await checkDB()
  if (res.code === 0) {
    if (!res.data?.needInit) {
      系统已熟.value = true
    }
  }
}
证系统()

const 跳转初始化 = async () => {
  await router.push({ name: 'Init' })
}


</script>

<style scoped lang="scss">
@use "./login.scss";
</style>
